package com.econ.powercloud.ems.common.enums;

/**
 * @ Description:全景分析统计量计算的时间
 * @ Author：hgp
 * @ Create:2022-11-29-9:47
 */
public enum DayType implements EnumMethod {
    ONE_DAY(1, "一天", 24),
    SEVEN_DAY(2, "七天", 168),
    MONTH(3, "一月（30天）", 720),
    YEAR(4, "一年（365天）", 8760),
    ALL(5, "累计总量", 0),
    ;

    private Integer code;
    private String desc;
    private Integer hour;

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public Integer getHour() {
        return hour;
    }

    DayType(int code, String desc, Integer hour) {
        this.code = code;
        this.desc = desc;
        this.hour = hour;
    }

    public static String getDescFromCode(int code) {
        for (DayType type : DayType.values()) {
            if (type.getCode() == code) {
                return type.getDesc();
            }
        }
        return null;
    }

    public static Integer getHourFromCode(int code) {
        for (DayType type : DayType.values()) {
            if (type.getCode() == code) {
                return type.getHour();
            }
        }
        return Integer.MAX_VALUE;
    }

    public static Integer fromDesc(String desc) {
        for (DayType type : DayType.values()) {
            if (type.getDesc().equals(desc)) {
                return type.getCode();
            }
        }
        return null;
    }
}
